<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Digest::SHA - Perl extension for SHA-1/224/256/384/512 - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/Digest::SHA">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Digest::SHA.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/Digest::SHA">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/Digest::SHA">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/Digest::SHA">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/Digest::SHA">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/Digest::SHA">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/Digest::SHA">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/Digest::SHA">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/Digest::SHA">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/Digest::SHA">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/Digest::SHA">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/Digest::SHA">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/Digest::SHA">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/Digest::SHA">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/Digest::SHA">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/Digest::SHA">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/Digest::SHA">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/Digest::SHA">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/Digest::SHA">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/Digest::SHA">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/Digest::SHA">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/Digest::SHA">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/Digest::SHA">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/Digest::SHA">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/Digest::SHA">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/Digest::SHA">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/Digest::SHA">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/Digest::SHA">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/Digest::SHA">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/Digest::SHA">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/Digest::SHA">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/Digest::SHA">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/Digest::SHA">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/Digest::SHA">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/Digest::SHA">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/Digest::SHA">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/Digest::SHA">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/Digest::SHA">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/Digest::SHA">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/Digest::SHA">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/Digest::SHA">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/Digest::SHA">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/Digest::SHA">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/Digest::SHA">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/Digest::SHA">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/Digest::SHA">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/Digest::SHA">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/Digest::SHA">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/Digest::SHA">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/Digest::SHA">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/Digest::SHA">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/Digest::SHA">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/Digest::SHA">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/Digest::SHA">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/Digest::SHA">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/Digest::SHA">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/Digest::SHA">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/Digest::SHA">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/Digest::SHA">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/Digest::SHA">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/Digest::SHA">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/Digest::SHA">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/Digest::SHA">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/Digest::SHA">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/Digest::SHA">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/Digest::SHA">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/Digest::SHA">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/Digest::SHA">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/Digest::SHA">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/Digest::SHA">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/Digest::SHA">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/Digest::SHA">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/Digest::SHA">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/Digest::SHA">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/Digest::SHA">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/Digest::SHA">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/Digest::SHA">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/Digest::SHA">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/Digest::SHA">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/Digest::SHA">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/Digest::SHA">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Digest::SHA.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/Digest::SHA">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/Digest::SHA">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/Digest::SHA">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/Digest::SHA">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/Digest::SHA">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/Digest::SHA">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/Digest::SHA">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/Digest::SHA">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/Digest::SHA">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/Digest::SHA">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/Digest::SHA">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/Digest::SHA">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/Digest::SHA">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/Digest::SHA">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/Digest::SHA">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/Digest::SHA">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/Digest::SHA">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/Digest::SHA">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/Digest::SHA">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/Digest::SHA">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/Digest::SHA">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/Digest::SHA">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/Digest::SHA">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/Digest::SHA">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/Digest::SHA">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/Digest::SHA">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/Digest::SHA">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/Digest::SHA">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/Digest::SHA">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/Digest::SHA">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/Digest::SHA">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/Digest::SHA">5.35.1</a>
          <a class="dropdown-item active" href="./Digest::SHA.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Digest::SHA.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="./Digest::SHA.html">Digest::SHA</a>
          <div id="more">
            (<a href="./Digest::SHA.txt">source</a>,
            <a href="https://metacpan.org/pod/Digest::SHA">CPAN</a>)
          </div>
            <div id="moduleversion">version 6.02</div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#SYNOPSIS">SYNOPSIS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#SYNOPSIS-(HMAC-SHA)">SYNOPSIS (HMAC-SHA)</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#ABSTRACT">ABSTRACT</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#DESCRIPTION">DESCRIPTION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#UNICODE-AND-SIDE-EFFECTS">UNICODE AND SIDE EFFECTS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#NIST-STATEMENT-ON-SHA-1">NIST STATEMENT ON SHA-1</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#PADDING-OF-BASE64-DIGESTS">PADDING OF BASE64 DIGESTS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#EXPORT">EXPORT</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#EXPORTABLE-FUNCTIONS">EXPORTABLE FUNCTIONS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#SEE-ALSO">SEE ALSO</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#AUTHOR">AUTHOR</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#ACKNOWLEDGMENTS">ACKNOWLEDGMENTS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::SHA.html#COPYRIGHT-AND-LICENSE">COPYRIGHT AND LICENSE</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="./Digest::SHA.html#NAME">#</a>NAME</h1>

<p>Digest::SHA - Perl extension for SHA-1/224/256/384/512</p>

<h1 id="SYNOPSIS"><a class="permalink" href="./Digest::SHA.html#SYNOPSIS">#</a>SYNOPSIS</h1>

<p>In programs:</p>

<pre><code>	# Functional interface

use Digest::SHA qw(sha1 sha1_hex sha1_base64 ...);

$digest = sha1($data);
$digest = sha1_hex($data);
$digest = sha1_base64($data);

$digest = sha256($data);
$digest = sha384_hex($data);
$digest = sha512_base64($data);

	# Object-oriented

use Digest::SHA;

$sha = Digest::SHA-&gt;new($alg);

$sha-&gt;add($data);		# feed data into stream

$sha-&gt;addfile(*F);
$sha-&gt;addfile($filename);

$sha-&gt;add_bits($bits);
$sha-&gt;add_bits($data, $nbits);

$sha_copy = $sha-&gt;clone;	# make copy of digest object
$state = $sha-&gt;getstate;	# save current state to string
$sha-&gt;putstate($state);		# restore previous $state

$digest = $sha-&gt;digest;		# compute digest
$digest = $sha-&gt;hexdigest;
$digest = $sha-&gt;b64digest;</code></pre>

<p>From the command line:</p>

<pre><code class="plaintext">$ shasum files

$ shasum --help</code></pre>

<h1 id="SYNOPSIS-(HMAC-SHA)"><a class="permalink" href="./Digest::SHA.html#SYNOPSIS-(HMAC-SHA)">#</a><a id="SYNOPSIS1"></a><a id="SYNOPSIS-HMAC-SHA"></a>SYNOPSIS (HMAC-SHA)</h1>

<pre><code>	# Functional interface only

use Digest::SHA qw(hmac_sha1 hmac_sha1_hex ...);

$digest = hmac_sha1($data, $key);
$digest = hmac_sha224_hex($data, $key);
$digest = hmac_sha256_base64($data, $key);</code></pre>

<h1 id="ABSTRACT"><a class="permalink" href="./Digest::SHA.html#ABSTRACT">#</a>ABSTRACT</h1>

<p>Digest::SHA is a complete implementation of the NIST Secure Hash Standard. It gives Perl programmers a convenient way to calculate SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256 message digests. The module can handle all types of input, including partial-byte data.</p>

<h1 id="DESCRIPTION"><a class="permalink" href="./Digest::SHA.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>Digest::SHA is written in C for speed. If your platform lacks a C compiler, you can install the functionally equivalent (but much slower) <a href="./Digest::SHA::PurePerl.html">Digest::SHA::PurePerl</a> module.</p>

<p>The programming interface is easy to use: it&#39;s the same one found in CPAN&#39;s <a href="Digest.html">Digest</a> module. So, if your applications currently use <a href="./Digest::MD5.html">Digest::MD5</a> and you&#39;d prefer the stronger security of SHA, it&#39;s a simple matter to convert them.</p>

<p>The interface provides two ways to calculate digests: all-at-once, or in stages. To illustrate, the following short program computes the SHA-256 digest of &quot;hello world&quot; using each approach:</p>

<pre><code>use Digest::SHA qw(sha256_hex);

$data = &quot;hello world&quot;;
@frags = split(//, $data);

# all-at-once (Functional style)
$digest1 = sha256_hex($data);

# in-stages (OOP style)
$state = Digest::SHA-&gt;new(256);
for (@frags) { $state-&gt;add($_) }
$digest2 = $state-&gt;hexdigest;

print $digest1 eq $digest2 ?
	&quot;whew!\n&quot; : &quot;oops!\n&quot;;</code></pre>

<p>To calculate the digest of an n-bit message where <i>n</i> is not a multiple of 8, use the <i>add_bits()</i> method. For example, consider the 446-bit message consisting of the bit-string &quot;110&quot; repeated 148 times, followed by &quot;11&quot;. Here&#39;s how to display its SHA-1 digest:</p>

<pre><code>use Digest::SHA;
$bits = &quot;110&quot; x 148 . &quot;11&quot;;
$sha = Digest::SHA-&gt;new(1)-&gt;add_bits($bits);
print $sha-&gt;hexdigest, &quot;\n&quot;;</code></pre>

<p>Note that for larger bit-strings, it&#39;s more efficient to use the two-argument version <i>add_bits($data, $nbits)</i>, where <i>$data</i> is in the customary packed binary format used for Perl strings.</p>

<p>The module also lets you save intermediate SHA states to a string. The <i>getstate()</i> method generates portable, human-readable text describing the current state of computation. You can subsequently restore that state with <i>putstate()</i> to resume where the calculation left off.</p>

<p>To see what a state description looks like, just run the following:</p>

<pre><code>use Digest::SHA;
print Digest::SHA-&gt;new-&gt;add(&quot;Shaw&quot; x 1962)-&gt;getstate;</code></pre>

<p>As an added convenience, the Digest::SHA module offers routines to calculate keyed hashes using the HMAC-SHA-1/224/256/384/512 algorithms. These services exist in functional form only, and mimic the style and behavior of the <i>sha()</i>, <i>sha_hex()</i>, and <i>sha_base64()</i> functions.</p>

<pre><code># Test vector from draft-ietf-ipsec-ciph-sha-256-01.txt

use Digest::SHA qw(hmac_sha256_hex);
print hmac_sha256_hex(&quot;Hi There&quot;, chr(0x0b) x 32), &quot;\n&quot;;</code></pre>

<h1 id="UNICODE-AND-SIDE-EFFECTS"><a class="permalink" href="./Digest::SHA.html#UNICODE-AND-SIDE-EFFECTS">#</a><a id="UNICODE"></a>UNICODE AND SIDE EFFECTS</h1>

<p>Perl supports Unicode strings as of version 5.6. Such strings may contain wide characters, namely, characters whose ordinal values are greater than 255. This can cause problems for digest algorithms such as SHA that are specified to operate on sequences of bytes.</p>

<p>The rule by which Digest::SHA handles a Unicode string is easy to state, but potentially confusing to grasp: the string is interpreted as a sequence of byte values, where each byte value is equal to the ordinal value (viz. code point) of its corresponding Unicode character. That way, the Unicode string &#39;abc&#39; has exactly the same digest value as the ordinary string &#39;abc&#39;.</p>

<p>Since a wide character does not fit into a byte, the Digest::SHA routines croak if they encounter one. Whereas if a Unicode string contains no wide characters, the module accepts it quite happily. The following code illustrates the two cases:</p>

<pre><code>$str1 = pack(&#39;U*&#39;, (0..255));
print sha1_hex($str1);		# ok

$str2 = pack(&#39;U*&#39;, (0..256));
print sha1_hex($str2);		# croaks</code></pre>

<p>Be aware that the digest routines silently convert UTF-8 input into its equivalent byte sequence in the native encoding (cf. utf8::downgrade). This side effect influences only the way Perl stores the data internally, but otherwise leaves the actual value of the data intact.</p>

<h1 id="NIST-STATEMENT-ON-SHA-1"><a class="permalink" href="./Digest::SHA.html#NIST-STATEMENT-ON-SHA-1">#</a><a id="NIST"></a>NIST STATEMENT ON SHA-1</h1>

<p>NIST acknowledges that the work of Prof. Xiaoyun Wang constitutes a practical collision attack on SHA-1. Therefore, NIST encourages the rapid adoption of the SHA-2 hash functions (e.g. SHA-256) for applications requiring strong collision resistance, such as digital signatures.</p>

<p>ref. <a href="http://csrc.nist.gov/groups/ST/hash/statement.html">http://csrc.nist.gov/groups/ST/hash/statement.html</a></p>

<h1 id="PADDING-OF-BASE64-DIGESTS"><a class="permalink" href="./Digest::SHA.html#PADDING-OF-BASE64-DIGESTS">#</a><a id="PADDING"></a>PADDING OF BASE64 DIGESTS</h1>

<p>By convention, CPAN Digest modules do <b>not</b> pad their Base64 output. Problems can occur when feeding such digests to other software that expects properly padded Base64 encodings.</p>

<p>For the time being, any necessary padding must be done by the user. Fortunately, this is a simple operation: if the length of a Base64-encoded digest isn&#39;t a multiple of 4, simply append &quot;=&quot; characters to the end of the digest until it is:</p>

<pre><code>while (length($b64_digest) % 4) {
	$b64_digest .= &#39;=&#39;;
}</code></pre>

<p>To illustrate, <i>sha256_base64(&quot;abc&quot;)</i> is computed to be</p>

<pre><code class="plaintext">ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0</code></pre>

<p>which has a length of 43. So, the properly padded version is</p>

<pre><code class="plaintext">ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=</code></pre>

<h1 id="EXPORT"><a class="permalink" href="./Digest::SHA.html#EXPORT">#</a>EXPORT</h1>

<p>None by default.</p>

<h1 id="EXPORTABLE-FUNCTIONS"><a class="permalink" href="./Digest::SHA.html#EXPORTABLE-FUNCTIONS">#</a><a id="EXPORTABLE"></a>EXPORTABLE FUNCTIONS</h1>

<p>Provided your C compiler supports a 64-bit type (e.g. the <i>long long</i> of C99, or <i>__int64</i> used by Microsoft C/C++), all of these functions will be available for use. Otherwise, you won&#39;t be able to perform the SHA-384 and SHA-512 transforms, both of which require 64-bit operations.</p>

<p><i>Functional style</i></p>

<dl>

<dt id="sha1($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha1($data,-...)">#</a><a id="sha1"></a><a id="sha1-data"></a><b>sha1($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha224($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha224($data,-...)">#</a><a id="sha224"></a><a id="sha224-data"></a><b>sha224($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha256($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha256($data,-...)">#</a><a id="sha256"></a><a id="sha256-data"></a><b>sha256($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha384($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha384($data,-...)">#</a><a id="sha384"></a><a id="sha384-data"></a><b>sha384($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha512($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha512($data,-...)">#</a><a id="sha512"></a><a id="sha512-data"></a><b>sha512($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha512224($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha512224($data,-...)">#</a><a id="sha512224"></a><a id="sha512224-data"></a><b>sha512224($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha512256($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha512256($data,-...)">#</a><a id="sha512256"></a><a id="sha512256-data"></a><b>sha512256($data, ...)</b></dt>
<dd>

<p>Logically joins the arguments into a single string, and returns its SHA-1/224/256/384/512 digest encoded as a binary string.</p>

</dd>
<dt id="sha1_hex($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha1_hex($data,-...)">#</a><a id="sha1_hex"></a><a id="sha1_hex-data"></a><b>sha1_hex($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha224_hex($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha224_hex($data,-...)">#</a><a id="sha224_hex"></a><a id="sha224_hex-data"></a><b>sha224_hex($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha256_hex($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha256_hex($data,-...)">#</a><a id="sha256_hex"></a><a id="sha256_hex-data"></a><b>sha256_hex($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha384_hex($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha384_hex($data,-...)">#</a><a id="sha384_hex"></a><a id="sha384_hex-data"></a><b>sha384_hex($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha512_hex($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha512_hex($data,-...)">#</a><a id="sha512_hex"></a><a id="sha512_hex-data"></a><b>sha512_hex($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha512224_hex($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha512224_hex($data,-...)">#</a><a id="sha512224_hex"></a><a id="sha512224_hex-data"></a><b>sha512224_hex($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha512256_hex($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha512256_hex($data,-...)">#</a><a id="sha512256_hex"></a><a id="sha512256_hex-data"></a><b>sha512256_hex($data, ...)</b></dt>
<dd>

<p>Logically joins the arguments into a single string, and returns its SHA-1/224/256/384/512 digest encoded as a hexadecimal string.</p>

</dd>
<dt id="sha1_base64($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha1_base64($data,-...)">#</a><a id="sha1_base64"></a><a id="sha1_base64-data"></a><b>sha1_base64($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha224_base64($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha224_base64($data,-...)">#</a><a id="sha224_base64"></a><a id="sha224_base64-data"></a><b>sha224_base64($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha256_base64($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha256_base64($data,-...)">#</a><a id="sha256_base64"></a><a id="sha256_base64-data"></a><b>sha256_base64($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha384_base64($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha384_base64($data,-...)">#</a><a id="sha384_base64"></a><a id="sha384_base64-data"></a><b>sha384_base64($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha512_base64($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha512_base64($data,-...)">#</a><a id="sha512_base64"></a><a id="sha512_base64-data"></a><b>sha512_base64($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha512224_base64($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha512224_base64($data,-...)">#</a><a id="sha512224_base64"></a><a id="sha512224_base64-data"></a><b>sha512224_base64($data, ...)</b></dt>
<dd>

</dd>
<dt id="sha512256_base64($data,-...)"><a class="permalink" href="./Digest::SHA.html#sha512256_base64($data,-...)">#</a><a id="sha512256_base64"></a><a id="sha512256_base64-data"></a><b>sha512256_base64($data, ...)</b></dt>
<dd>

<p>Logically joins the arguments into a single string, and returns its SHA-1/224/256/384/512 digest encoded as a Base64 string.</p>

<p>It&#39;s important to note that the resulting string does <b>not</b> contain the padding characters typical of Base64 encodings. This omission is deliberate, and is done to maintain compatibility with the family of CPAN Digest modules. See <a href="./Digest::SHA.html#PADDING-OF-BASE64-DIGESTS">&quot;PADDING OF BASE64 DIGESTS&quot;</a> for details.</p>

</dd>
</dl>

<p><i>OOP style</i></p>

<dl>

<dt id="new($alg)"><a class="permalink" href="./Digest::SHA.html#new($alg)">#</a><a id="new"></a><a id="new-alg"></a><b>new($alg)</b></dt>
<dd>

<p>Returns a new Digest::SHA object. Allowed values for <i>$alg</i> are 1, 224, 256, 384, 512, 512224, or 512256. It&#39;s also possible to use common string representations of the algorithm (e.g. &quot;sha256&quot;, &quot;SHA-384&quot;). If the argument is missing, SHA-1 will be used by default.</p>

<p>Invoking <i>new</i> as an instance method will reset the object to the initial state associated with <i>$alg</i>. If the argument is missing, the object will continue using the same algorithm that was selected at creation.</p>

</dd>
<dt id="reset($alg)"><a class="permalink" href="./Digest::SHA.html#reset($alg)">#</a><a id="reset"></a><a id="reset-alg"></a><b>reset($alg)</b></dt>
<dd>

<p>This method has exactly the same effect as <i>new($alg)</i>. In fact, <i>reset</i> is just an alias for <i>new</i>.</p>

</dd>
<dt id="hashsize"><a class="permalink" href="./Digest::SHA.html#hashsize">#</a><b>hashsize</b></dt>
<dd>

<p>Returns the number of digest bits for this object. The values are 160, 224, 256, 384, 512, 224, and 256 for SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224 and SHA-512/256, respectively.</p>

</dd>
<dt id="algorithm"><a class="permalink" href="./Digest::SHA.html#algorithm">#</a><b>algorithm</b></dt>
<dd>

<p>Returns the digest algorithm for this object. The values are 1, 224, 256, 384, 512, 512224, and 512256 for SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256, respectively.</p>

</dd>
<dt id="clone"><a class="permalink" href="./Digest::SHA.html#clone">#</a><b>clone</b></dt>
<dd>

<p>Returns a duplicate copy of the object.</p>

</dd>
<dt id="add($data,-...)"><a class="permalink" href="./Digest::SHA.html#add($data,-...)">#</a><a id="add"></a><a id="add-data"></a><b>add($data, ...)</b></dt>
<dd>

<p>Logically joins the arguments into a single string, and uses it to update the current digest state. In other words, the following statements have the same effect:</p>

<pre><code>$sha-&gt;add(&quot;a&quot;); $sha-&gt;add(&quot;b&quot;); $sha-&gt;add(&quot;c&quot;);
$sha-&gt;add(&quot;a&quot;)-&gt;add(&quot;b&quot;)-&gt;add(&quot;c&quot;);
$sha-&gt;add(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;);
$sha-&gt;add(&quot;abc&quot;);</code></pre>

<p>The return value is the updated object itself.</p>

</dd>
<dt id="add_bits($data,-$nbits)"><a class="permalink" href="./Digest::SHA.html#add_bits($data,-$nbits)">#</a><a id="add_bits"></a><a id="add_bits-data-nbits"></a><b>add_bits($data, $nbits)</b></dt>
<dd>

</dd>
<dt id="add_bits($bits)"><a class="permalink" href="./Digest::SHA.html#add_bits($bits)">#</a><a id="add_bits1"></a><a id="add_bits-bits"></a><b>add_bits($bits)</b></dt>
<dd>

<p>Updates the current digest state by appending bits to it. The return value is the updated object itself.</p>

<p>The first form causes the most-significant <i>$nbits</i> of <i>$data</i> to be appended to the stream. The <i>$data</i> argument is in the customary binary format used for Perl strings.</p>

<p>The second form takes an ASCII string of &quot;0&quot; and &quot;1&quot; characters as its argument. It&#39;s equivalent to</p>

<pre><code>$sha-&gt;add_bits(pack(&quot;B*&quot;, $bits), length($bits));</code></pre>

<p>So, the following two statements do the same thing:</p>

<pre><code>$sha-&gt;add_bits(&quot;111100001010&quot;);
$sha-&gt;add_bits(&quot;\xF0\xA0&quot;, 12);</code></pre>

<p>Note that SHA-1 and SHA-2 use <i>most-significant-bit ordering</i> for their internal state. This means that</p>

<pre><code>$sha3-&gt;add_bits(&quot;110&quot;);</code></pre>

<p>is equivalent to</p>

<pre><code>$sha3-&gt;add_bits(&quot;1&quot;)-&gt;add_bits(&quot;1&quot;)-&gt;add_bits(&quot;0&quot;);</code></pre>

</dd>
<dt id="addfile(*FILE)"><a class="permalink" href="./Digest::SHA.html#addfile(*FILE)">#</a><a id="addfile"></a><a id="addfile-FILE"></a><b>addfile(*FILE)</b></dt>
<dd>

<p>Reads from <i>FILE</i> until EOF, and appends that data to the current state. The return value is the updated object itself.</p>

</dd>
<dt id="addfile($filename-[,-$mode])"><a class="permalink" href="./Digest::SHA.html#addfile($filename-%5B,-$mode%5D)">#</a><a id="addfile1"></a><a id="addfile-filename-mode"></a><b>addfile($filename [, $mode])</b></dt>
<dd>

<p>Reads the contents of <i>$filename</i>, and appends that data to the current state. The return value is the updated object itself.</p>

<p>By default, <i>$filename</i> is simply opened and read; no special modes or I/O disciplines are used. To change this, set the optional <i>$mode</i> argument to one of the following values:</p>

<pre><code class="plaintext">&quot;b&quot;	read file in binary mode

&quot;U&quot;	use universal newlines

&quot;0&quot;	use BITS mode</code></pre>

<p>The &quot;U&quot; mode is modeled on Python&#39;s &quot;Universal Newlines&quot; concept, whereby DOS and Mac OS line terminators are converted internally to UNIX newlines before processing. This ensures consistent digest values when working simultaneously across multiple file systems. <b>The &quot;U&quot; mode influences only text files</b>, namely those passing Perl&#39;s <i>-T</i> test; binary files are processed with no translation whatsoever.</p>

<p>The BITS mode (&quot;0&quot;) interprets the contents of <i>$filename</i> as a logical stream of bits, where each ASCII &#39;0&#39; or &#39;1&#39; character represents a 0 or 1 bit, respectively. All other characters are ignored. This provides a convenient way to calculate the digest values of partial-byte data by using files, rather than having to write separate programs employing the <i>add_bits</i> method.</p>

</dd>
<dt id="getstate"><a class="permalink" href="./Digest::SHA.html#getstate">#</a><b>getstate</b></dt>
<dd>

<p>Returns a string containing a portable, human-readable representation of the current SHA state.</p>

</dd>
<dt id="putstate($str)"><a class="permalink" href="./Digest::SHA.html#putstate($str)">#</a><a id="putstate"></a><a id="putstate-str"></a><b>putstate($str)</b></dt>
<dd>

<p>Returns a Digest::SHA object representing the SHA state contained in <i>$str</i>. The format of <i>$str</i> matches the format of the output produced by method <i>getstate</i>. If called as a class method, a new object is created; if called as an instance method, the object is reset to the state contained in <i>$str</i>.</p>

</dd>
<dt id="dump($filename)"><a class="permalink" href="./Digest::SHA.html#dump($filename)">#</a><a id="dump"></a><a id="dump-filename"></a><b>dump($filename)</b></dt>
<dd>

<p>Writes the output of <i>getstate</i> to <i>$filename</i>. If the argument is missing, or equal to the empty string, the state information will be written to STDOUT.</p>

</dd>
<dt id="load($filename)"><a class="permalink" href="./Digest::SHA.html#load($filename)">#</a><a id="load"></a><a id="load-filename"></a><b>load($filename)</b></dt>
<dd>

<p>Returns a Digest::SHA object that results from calling <i>putstate</i> on the contents of <i>$filename</i>. If the argument is missing, or equal to the empty string, the state information will be read from STDIN.</p>

</dd>
<dt id="digest"><a class="permalink" href="./Digest::SHA.html#digest">#</a><b>digest</b></dt>
<dd>

<p>Returns the digest encoded as a binary string.</p>

<p>Note that the <i>digest</i> method is a read-once operation. Once it has been performed, the Digest::SHA object is automatically reset in preparation for calculating another digest value. Call <i>$sha-&gt;clone-&gt;digest</i> if it&#39;s necessary to preserve the original digest state.</p>

</dd>
<dt id="hexdigest"><a class="permalink" href="./Digest::SHA.html#hexdigest">#</a><b>hexdigest</b></dt>
<dd>

<p>Returns the digest encoded as a hexadecimal string.</p>

<p>Like <i>digest</i>, this method is a read-once operation. Call <i>$sha-&gt;clone-&gt;hexdigest</i> if it&#39;s necessary to preserve the original digest state.</p>

</dd>
<dt id="b64digest"><a class="permalink" href="./Digest::SHA.html#b64digest">#</a><b>b64digest</b></dt>
<dd>

<p>Returns the digest encoded as a Base64 string.</p>

<p>Like <i>digest</i>, this method is a read-once operation. Call <i>$sha-&gt;clone-&gt;b64digest</i> if it&#39;s necessary to preserve the original digest state.</p>

<p>It&#39;s important to note that the resulting string does <b>not</b> contain the padding characters typical of Base64 encodings. This omission is deliberate, and is done to maintain compatibility with the family of CPAN Digest modules. See <a href="./Digest::SHA.html#PADDING-OF-BASE64-DIGESTS">&quot;PADDING OF BASE64 DIGESTS&quot;</a> for details.</p>

</dd>
</dl>

<p><i>HMAC-SHA-1/224/256/384/512</i></p>

<dl>

<dt id="hmac_sha1($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha1($data,-$key)">#</a><a id="hmac_sha1"></a><a id="hmac_sha1-data-key"></a><b>hmac_sha1($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha224($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha224($data,-$key)">#</a><a id="hmac_sha224"></a><a id="hmac_sha224-data-key"></a><b>hmac_sha224($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha256($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha256($data,-$key)">#</a><a id="hmac_sha256"></a><a id="hmac_sha256-data-key"></a><b>hmac_sha256($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha384($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha384($data,-$key)">#</a><a id="hmac_sha384"></a><a id="hmac_sha384-data-key"></a><b>hmac_sha384($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha512($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha512($data,-$key)">#</a><a id="hmac_sha512"></a><a id="hmac_sha512-data-key"></a><b>hmac_sha512($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha512224($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha512224($data,-$key)">#</a><a id="hmac_sha512224"></a><a id="hmac_sha512224-data-key"></a><b>hmac_sha512224($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha512256($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha512256($data,-$key)">#</a><a id="hmac_sha512256"></a><a id="hmac_sha512256-data-key"></a><b>hmac_sha512256($data, $key)</b></dt>
<dd>

<p>Returns the HMAC-SHA-1/224/256/384/512 digest of <i>$data</i>/<i>$key</i>, with the result encoded as a binary string. Multiple <i>$data</i> arguments are allowed, provided that <i>$key</i> is the last argument in the list.</p>

</dd>
<dt id="hmac_sha1_hex($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha1_hex($data,-$key)">#</a><a id="hmac_sha1_hex"></a><a id="hmac_sha1_hex-data-key"></a><b>hmac_sha1_hex($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha224_hex($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha224_hex($data,-$key)">#</a><a id="hmac_sha224_hex"></a><a id="hmac_sha224_hex-data-key"></a><b>hmac_sha224_hex($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha256_hex($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha256_hex($data,-$key)">#</a><a id="hmac_sha256_hex"></a><a id="hmac_sha256_hex-data-key"></a><b>hmac_sha256_hex($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha384_hex($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha384_hex($data,-$key)">#</a><a id="hmac_sha384_hex"></a><a id="hmac_sha384_hex-data-key"></a><b>hmac_sha384_hex($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha512_hex($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha512_hex($data,-$key)">#</a><a id="hmac_sha512_hex"></a><a id="hmac_sha512_hex-data-key"></a><b>hmac_sha512_hex($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha512224_hex($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha512224_hex($data,-$key)">#</a><a id="hmac_sha512224_hex"></a><a id="hmac_sha512224_hex-data-key"></a><b>hmac_sha512224_hex($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha512256_hex($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha512256_hex($data,-$key)">#</a><a id="hmac_sha512256_hex"></a><a id="hmac_sha512256_hex-data-key"></a><b>hmac_sha512256_hex($data, $key)</b></dt>
<dd>

<p>Returns the HMAC-SHA-1/224/256/384/512 digest of <i>$data</i>/<i>$key</i>, with the result encoded as a hexadecimal string. Multiple <i>$data</i> arguments are allowed, provided that <i>$key</i> is the last argument in the list.</p>

</dd>
<dt id="hmac_sha1_base64($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha1_base64($data,-$key)">#</a><a id="hmac_sha1_base64"></a><a id="hmac_sha1_base64-data-key"></a><b>hmac_sha1_base64($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha224_base64($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha224_base64($data,-$key)">#</a><a id="hmac_sha224_base64"></a><a id="hmac_sha224_base64-data-key"></a><b>hmac_sha224_base64($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha256_base64($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha256_base64($data,-$key)">#</a><a id="hmac_sha256_base64"></a><a id="hmac_sha256_base64-data-key"></a><b>hmac_sha256_base64($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha384_base64($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha384_base64($data,-$key)">#</a><a id="hmac_sha384_base64"></a><a id="hmac_sha384_base64-data-key"></a><b>hmac_sha384_base64($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha512_base64($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha512_base64($data,-$key)">#</a><a id="hmac_sha512_base64"></a><a id="hmac_sha512_base64-data-key"></a><b>hmac_sha512_base64($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha512224_base64($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha512224_base64($data,-$key)">#</a><a id="hmac_sha512224_base64"></a><a id="hmac_sha512224_base64-data-key"></a><b>hmac_sha512224_base64($data, $key)</b></dt>
<dd>

</dd>
<dt id="hmac_sha512256_base64($data,-$key)"><a class="permalink" href="./Digest::SHA.html#hmac_sha512256_base64($data,-$key)">#</a><a id="hmac_sha512256_base64"></a><a id="hmac_sha512256_base64-data-key"></a><b>hmac_sha512256_base64($data, $key)</b></dt>
<dd>

<p>Returns the HMAC-SHA-1/224/256/384/512 digest of <i>$data</i>/<i>$key</i>, with the result encoded as a Base64 string. Multiple <i>$data</i> arguments are allowed, provided that <i>$key</i> is the last argument in the list.</p>

<p>It&#39;s important to note that the resulting string does <b>not</b> contain the padding characters typical of Base64 encodings. This omission is deliberate, and is done to maintain compatibility with the family of CPAN Digest modules. See <a href="./Digest::SHA.html#PADDING-OF-BASE64-DIGESTS">&quot;PADDING OF BASE64 DIGESTS&quot;</a> for details.</p>

</dd>
</dl>

<h1 id="SEE-ALSO"><a class="permalink" href="./Digest::SHA.html#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1>

<p><a href="Digest.html">Digest</a>, <a href="./Digest::SHA::PurePerl.html">Digest::SHA::PurePerl</a></p>

<p>The Secure Hash Standard (Draft FIPS PUB 180-4) can be found at:</p>

<p><a href="http://csrc.nist.gov/publications/drafts/fips180-4/Draft-FIPS180-4_Feb2011.pdf">http://csrc.nist.gov/publications/drafts/fips180-4/Draft-FIPS180-4_Feb2011.pdf</a></p>

<p>The Keyed-Hash Message Authentication Code (HMAC):</p>

<p><a href="http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf">http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf</a></p>

<h1 id="AUTHOR"><a class="permalink" href="./Digest::SHA.html#AUTHOR">#</a>AUTHOR</h1>

<pre><code>Mark Shelor	&lt;mshelor@cpan.org&gt;</code></pre>

<h1 id="ACKNOWLEDGMENTS"><a class="permalink" href="./Digest::SHA.html#ACKNOWLEDGMENTS">#</a>ACKNOWLEDGMENTS</h1>

<p>The author is particularly grateful to</p>

<pre><code class="plaintext">Gisle Aas
H. Merijn Brand
Sean Burke
Chris Carey
Alexandr Ciornii
Chris David
Jim Doble
Thomas Drugeon
Julius Duque
Jeffrey Friedl
Robert Gilmour
Brian Gladman
Jarkko Hietaniemi
Adam Kennedy
Mark Lawrence
Andy Lester
Alex Muntada
Steve Peters
Chris Skiscim
Martin Thurn
Gunnar Wolf
Adam Woodbury</code></pre>

<p>&quot;who by trained skill rescued life from such great billows and such thick darkness and moored it in so perfect a calm and in so brilliant a light&quot; - Lucretius</p>

<h1 id="COPYRIGHT-AND-LICENSE"><a class="permalink" href="./Digest::SHA.html#COPYRIGHT-AND-LICENSE">#</a><a id="COPYRIGHT"></a>COPYRIGHT AND LICENSE</h1>

<p>Copyright (C) 2003-2018 Mark Shelor</p>

<p>This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p>

<p><a href="perlartistic.html">perlartistic</a></p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
